<!DOCTYPE html>
<script src="../../resources/js-test.js"></script>
<body>
<div id="div1"></div>
</body>
<script>
if (window.testRunner)
    testRunner.dumpAsText();

description("This test ensures we properly invalidate style when adding children affected by direct adjacent sibling selectors.");

var div1 = document.getElementById('div1');
var div2 = document.createElement('div');
div1.appendChild(div2);
var testDiv = document.createElement('div');
testDiv.id = "testDiv";
div2.appendChild(testDiv);
var style = document.createElement('style');
document.documentElement.firstChild.appendChild(style);
style.appendChild(document.createTextNode("#div1 > div + div > div { color: red; }\n"));

// Recalc style with our test div not matching the selector
document.defaultView.getComputedStyle(testDiv, "").color;

var trigger = document.createElement('div');
div1.insertBefore(trigger, div2);
shouldBe('document.defaultView.getComputedStyle(testDiv).color', '"rgb(255, 0, 0)"');

</script>
